<?php

namespace app\api\model;

use think\Model;
use think\Db;
use think\db\Where;

class ElectricityMeter extends Model
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'ty_electricity_meter';
    /**
     * 获取
     */
    public static  function addElec($data)
    {
        $where=[];
        $where['name'] = $data['name'];
        $info = Db::table('ty_electricity_meter')
            ->where($where)
            ->find();
        if($info){
            $res =   Db::table('ty_electricity_meter')
                ->where($where)
                ->update($data);
        }else{
            $res = Db::table('ty_electricity_meter')
                ->insert($data);
        }
        return $res;
    }
    public static  function updateInfo($name,$data)
    {
        $where=[];
        $where['name'] = $name;
        $res = Db::table('ty_electricity_meter')
                ->where($where)
                ->update($data);
        return $res;
    }
}
